package com.ease.framework.flex.controls {
   import mx.core.UIComponent;

   /**
    * The handle on the figure.
    */
   public class Handle extends UIComponent {
      // Does this handle let us resize down?
      public var resizeDown:Boolean = false;
      // Does this handle let us resize up?
      public var resizeUp:Boolean = false;
      // Does this handle let us resize left?
      public var resizeLeft:Boolean = false;
      // Does this handle let us resize to the right?
      public var resizeRight:Boolean = false;
      public var type:int = HandleLocationType.LOCATION_TOP;

      private var _cursorName:String;

      public function Handle() {
         super();
         width = 2.5;
         height = 2.5;
      }

      public function draw():void {
         graphics.clear();
         graphics.lineStyle(1, 0x03689A);
         graphics.beginFill(0xF4F6FF, 0.7);
         graphics.drawCircle(0, 0, 2.5);
         graphics.endFill();

      }

      /**
       * Returns true if this handle represents a handle in a corner.
       **/
      public function isCorner():Boolean {
         return 2 == ((resizeUp ? 1 : 0) + (resizeDown ? 1 : 0) + (resizeLeft ? 1 : 0) + (resizeRight ? 1 : 0)); // Corners can resize in exactly 2 directions.
      }

      public function getCursorName():String {
         if (!resizeDown && resizeLeft && !resizeRight && resizeUp) {
            return "SizeNWSE";
         }
         if (resizeDown && !resizeLeft && resizeRight && !resizeUp) {
            return "SizeNWSE";
         }
         if (!resizeDown && !resizeLeft && resizeRight && resizeUp) {
            return "SizeNESW";
         }
         if (resizeDown && resizeLeft && !resizeRight && !resizeUp) {
            return "SizeNESW";
         }
         if (resizeDown && !resizeLeft && !resizeRight && !resizeUp) {
            return "SizeNS";
         }
         if (!resizeDown && !resizeLeft && !resizeRight && resizeUp) {
            return "SizeNS";
         }
         if (!resizeDown && resizeLeft && !resizeRight && !resizeUp) {
            return "SizeWE";
         }
         if (!resizeDown && !resizeLeft && resizeRight && !resizeUp) {
            return "SizeWE";
         }
         return "";
      }

      public function set cursorName(value:String):void {
         this._cursorName = value;
      }

      public function get cursorName():String {
         return _cursorName;
      }
   }
}